import axios from 'axios'


const instance = axios.create({
    // timeout: 8000,
    // baseURL: 'http://localhost:3030',
    // baseURL:'http://192.168.2.220:8080', // 这是我的
    // baseURL: 'http://192.168.2.225:8080',
    // baseURL: 'http://192.168.2.228:8080', //这是你们涛爸爸的，不准动
    // baseURL: "http://192.168.2.225:8080"
    baseURL: "http://47.98.236.22:8080"
});

// console.log('store', store.getState());
// Add a request interceptor
instance.interceptors.request.use(
    function (config) {
        // Do something before request is sent

        // 携带token
        const token = sessionStorage.getItem("token")
        console.log("token:", token)
        token && (config.headers["token"] = token)

        return config;
    }, function (error) {
        // Do something with request error
        return Promise.reject(error);
    });

// Add a response interceptor
instance.interceptors.response.use(function (response) {
    // Any status code that lie within the range of 2xx cause this function to trigger
    // Do something with response data
    return response;
}, function (error) {
    // Any status codes that falls outside the range of 2xx cause this function to trigger
    // Do something with response error
    return Promise.reject(error);
});
export default instance